home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / programm / gemfsc20 / gemfsc20.lzh / GEMFUNCS / RCCONFIN.C < prev    next >
C/C++ Source or Header  |  1993-02-01  |  896b  |  39 lines

  1. /**************************************************************************
  2.  * RCCONFIN.C - Force destrect to be within boundrect.
  3.  *                If destrect is bigger than boundrect, precedence is given
  4.  *                to the upper and left edges (ie, dest will be aligned
  5.  *                with the boundry on the topleft edge).
  6.  *************************************************************************/
  7.  
  8. #include "gemfintl.h"
  9.  
  10. void rc_confine(pbound, pdest)
  11.     GRECT            *pbound;
  12.     register GRECT    *pdest;
  13. {
  14.     register short      diff;
  15.     VRECT            bound;
  16.     VRECT            dest;
  17.  
  18.     rc_gtov(pbound, &bound);
  19.     rc_gtov(pdest,    &dest);
  20.  
  21.     if (0 < (diff = dest.v_x2 - bound.v_x2)) {
  22.         pdest->g_x -= diff;
  23.     }
  24.  
  25.     if (0 < (diff = dest.v_y2 - bound.v_y2)) {
  26.         pdest->g_y -= diff;
  27.     }
  28.  
  29.     if (dest.v_x1 < bound.v_x1) {
  30.         pdest->g_x = bound.v_x1;
  31.     }
  32.  
  33.     if (dest.v_y1 < bound.v_y1) {
  34.         pdest->g_y = bound.v_y1;
  35.     }
  36.  
  37.     return;
  38. }
  39.